﻿@*YoursLC有源低代码 Create:φ创建者Creatorφ 2022-05-07 19:30:26 列表-此文件放置于Views/Data02/中*@

@using Think9.Models;
@{ ViewBag.Title = "Index";
    Layout = "~/Areas/Shared/_LayuiList.cshtml"; }

@*Data02行政区划*@
<input style="display:none" id="Pu_value">
<input style="display:none" id="Pu_tbid">
<input style="display:none" id="Pu_indexid">
<input style="display:none" id="Pu_id">
<input style="display:none" id="Pu_v">
<input style="display:none" id="_fwid" value="bi_Data02">
<fieldset class="table-fieldset" id="searchfield" style="display:none">
    <legend>快速查询 -<span id="sp_searchmode"></span> </legend>@*录入表管理/权限设置可设置查看编辑模式*@
    <div style="margin: 5px 5px 5px 5px">
        <form class="layui-form layui-form-pane" action=""  id="_formid">
			<div class="layui-row layui-col-space15">
				<div class="layui-col-md6">
					<label class="layui-form-label">编码</label>
					<div class="layui-input-block">
						<input type='text' name="inCode" id="inCode" autocomplete='off' class='layui-input'>
					</div>
				</div>
				<div class="layui-col-md6">
					<label class="layui-form-label">名称</label>
					<div class="layui-input-block">
						<input type='text' name="inName" id="inName" autocomplete='off' class='layui-input'>
					</div>
				</div>
			 </div>
			<div class="layui-row layui-col-space15">
				<div class="layui-col-md6">
					<label class="layui-form-label">备注</label>
					<div class="layui-input-block">
						<input type='text' name="inRemarks" id="inRemarks" autocomplete='off' class='layui-input'>
					</div>
				</div>
				<div class="layui-col-md6">
					<button type='button' class='layui-btn layui-btn-normal' id='search' lay-submit lay-filter='search'><i class='layui-icon layui-icon-search'></i></button> <button type='reset' class='layui-btn layui-btn-primary'><i class='layui-icon layui-icon-refresh'></i></button>
				</div>
			 </div>
        </form>
    </div>
</fieldset>

<table class="layui-hide" id="tableId" lay-filter="tableFilter"></table>
<script>
    layui.config({
        base: '/self_js/' /*自定义的js文件 位于wwwroot/self_js文件夹中*/
    });
    layui.use(["table", "form", "exLayer", "exUtils", "miniPage", "Data02"], function () {
        let table = layui.table;
        let form = layui.form;
        let miniPage = layui.miniPage;
        let exLayer = layui.exLayer;
        let exUtils = layui.exUtils;
        let mySelf = layui.Data02;

        let $ = layui.$;

        var openWH = miniPage.getOpenWidthHeight();

        form.render(); 

        $("#sp_searchmode").text("@ViewBag.SearchMode");

        let ThisTable = table.render({
            elem: "#tableId",
            url: "/Data02/GetPageListBySearch",
            limits: [10, 50, 100],
            limit: 10,
            method:"POST",
            page: true,
            defaultToolbar: [{ title: '搜索', layEvent: 'searchShow', icon: 'layui-icon-search' }, { title: '显示所有数据', layEvent: 'refresh', icon: 'layui-icon-refresh' }, 'filter', 'exports'],
            toolbar: "#toolbarTpl",
            cols: [[
                { title: "", width: 45, templet: "#is_lock" },
                { type: "numbers", title: ".NO"  },
                { title: "创建", sort: true, templet: '<span>{{d.BeginTime}} {{d.BeginUser}}<span>' },
				{ field: "inCode", title: "编码", width: 150, sort: true  },
				{ field: "inName", title: "名称", width: 150, sort: true  },
				{ field: "inRemarks", title: "备注", width: 150, sort: true  },
                { title: "操作", width: 210, align: "center", fixed: "right", templet: "#operation_Tpl" }
            ]],
            done: function (res, curr, count) {
            }
        });

         //查询
        form.on("submit(search)", function (data) {
            $("#searchfield").hide();
            ThisTable.reload({
                where: data.field,
                url: "/Data02/GetPageListBySearch",
                page: { curr: 1 }
            });
            return false;
        });



        table.on("toolbar(tableFilter)", function (obj) {
            switch (obj.event) {
                case "add":
                    add();
                    break;
                case "searchShow":
                    mySelf.searchShow();
                    break;
                case "refresh":
                    $("#searchfield").hide();
                    ThisTable.reload({
                        url: "/Data02/GetPageListBySearch?isAll=all",
                        page: { curr: 1 }
                    });
                    break;
            }
        });

        table.on("tool(tableFilter)", function (obj) {
            let data = obj.data;
            switch (obj.event) {
                case "detail":
                    //select弹出页面选择 pdf直接打开文件 安装MicrosoftRDLC打开wwwroot/Report中的rdlc文件可设计样式
                    showDetail($("#_fwid").val(), data.ListId, 'select');//showDetail在global.js中定义
                    break;
                case "record":
                    record(data.ListId);
                    break;
                case "edit":
                    edit(data.ListId);
                    break;
                case "del":
                    del(data.ListId);
                    break;
            }
        });

         function add() {
            exUtils.ajax("/Data02/BeforeAdd", "post", { type: 'add', listid: '0' }, true).done(function (response) {
                exLayer.open("Data02行政区划-新增数据", "/Data02/Form?listid=" + response.extra + "&pid=" + response.extra2 + "&type=add", '100%', '100%', '0px', '0px', null, null);
            }).fail(function (error) {
                console.log(error);
            });
        }

        function edit(id) {
            exUtils.ajax("/Data02/BeforeEdit", "post", { type: 'edit', listid: id }, true).done(function (response) {
                exLayer.open("Data02行政区划-编辑数据", "/Data02/Form?listid=" + id + "&pid=" + response.extra2 + "&type=edit", '100%', '100%', '0px', '0px', null, null);
            }).fail(function (error) {
                console.log(error);
            });
        }

        function record(id) {
            exLayer.open('记录查看', '/SysFlow/FlowRunList/RecordList?listid=' + id + "&fwid=" + $("#_fwid").val(), '100%', '100%', '0px', '0px', null, null);
        }

        function del(id) {
            exLayer.confirm("确定要删除吗？", function () {
                exUtils.ajax("/Data02/Delete", "get", { listid: id }, true).done(function (response) {
                    exUtils.tableSuccessMsg(response.message);
                    $(".layui-laypage-btn")[0].click();
                }).fail(function (error) {
                    console.log(error);
                });
            })
        }

        //弹出页面关闭后为控件赋值 无弹出页面可删除
        $("#Pu_value").click(function () {
            mySelf.getValueFromPopUp();
        });
    });
</script>
<!-- 头工具栏模板 -->
<script type="text/html" id="toolbarTpl">
    <button class="layui-btn layui-btn-normal layui-btn-sm" lay-event="add" id="add"><i class="fa fa-plus"></i>新增数据</button>
</script>
<!-- 锁定 -->
<script type='text/html' id='is_lock'>
    {{#  if(d.isLock == '0'){ }}
    <i class='fa fa-unlock'></i>
    {{#  }else{ }}
    <i class='fa fa-lock'></i>
    {{#  } }}
</script>
<!-- 行工具栏模板 -->
<script type="text/html" id="operation_Tpl">
    <a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="detail" id="detail">查看</a>
    <a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="record" id="record">记录</a>
    <a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="edit" id="edit">编辑</a>
    <a class="layui-btn layui-btn-xs layui-btn-danger" lay-event="del" id="del">删除</a>
</script>

<!-- 图片显示 -->
<script>
    function PopUpImg(id) {
        showImg(id);
    }
</script>